<?php

/**
 * This is the model class for table "pemberhentian".
 *
 * The followings are the available columns in table 'pemberhentian':
 * @property integer $ID_PEMBERHENTIAN
 * @property string $NAMA_PEMBERHENTIAN
 * @property string $ALAMAT_PEMBERHENTIAN
 * @property string $JENIS_PEMBERHENTIAN
 * @property integer $ID_KOTA
 *
 * The followings are the available model relations:
 * @property DetailPerjalananBus[] $detailPerjalananBuses
 * @property DetailPerjalananBus[] $detailPerjalananBuses1
 * @property DetailPerjalananKereta[] $detailPerjalananKeretas
 * @property DetailPerjalananKereta[] $detailPerjalananKeretas1
 * @property Kota $iDKOTA
 */
class Pemberhentian extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Pemberhentian the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'pemberhentian';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NAMA_PEMBERHENTIAN', 'required'),
			array('ID_KOTA', 'numerical', 'integerOnly'=>true),
			array('NAMA_PEMBERHENTIAN', 'length', 'max'=>20),
			array('ALAMAT_PEMBERHENTIAN', 'length', 'max'=>100),
			array('JENIS_PEMBERHENTIAN', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_PEMBERHENTIAN, NAMA_PEMBERHENTIAN, ALAMAT_PEMBERHENTIAN, JENIS_PEMBERHENTIAN, ID_KOTA', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'detailPerjalananBuses' => array(self::HAS_MANY, 'DetailPerjalananBus', 'PEM_ID_PEMBERHENTIAN'),
			'detailPerjalananBuses1' => array(self::HAS_MANY, 'DetailPerjalananBus', 'ID_PEMBERHENTIAN'),
			'detailPerjalananKeretas' => array(self::HAS_MANY, 'DetailPerjalananKereta', 'ID_PEMBERHENTIAN'),
			'detailPerjalananKeretas1' => array(self::HAS_MANY, 'DetailPerjalananKereta', 'PEM_ID_PEMBERHENTIAN'),
			'iDKOTA' => array(self::BELONGS_TO, 'Kota', 'ID_KOTA'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_PEMBERHENTIAN' => 'Id Pemberhentian',
			'NAMA_PEMBERHENTIAN' => 'Nama Pemberhentian',
			'ALAMAT_PEMBERHENTIAN' => 'Alamat Pemberhentian',
			'JENIS_PEMBERHENTIAN' => 'Jenis Pemberhentian',
			'ID_KOTA' => 'Id Kota',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_PEMBERHENTIAN',$this->ID_PEMBERHENTIAN);
		$criteria->compare('NAMA_PEMBERHENTIAN',$this->NAMA_PEMBERHENTIAN,true);
		$criteria->compare('ALAMAT_PEMBERHENTIAN',$this->ALAMAT_PEMBERHENTIAN,true);
		$criteria->compare('JENIS_PEMBERHENTIAN',$this->JENIS_PEMBERHENTIAN,true);
		$criteria->compare('ID_KOTA',$this->ID_KOTA);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}